package b.p.b;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/* compiled from: DiffUtil */
public class n {
    public static final Comparator<f> a = new a();

    /* compiled from: DiffUtil */
    public static class a implements Comparator<f> {
        public int compare(Object obj, Object obj2) {
            f fVar = (f) obj;
            f fVar2 = (f) obj2;
            int i = fVar.a - fVar2.a;
            return i == 0 ? fVar.b - fVar2.b : i;
        }
    }

    /* compiled from: DiffUtil */
    public static abstract class b {
        public abstract boolean a(int i, int i2);

        public abstract boolean b(int i, int i2);
    }

    /* compiled from: DiffUtil */
    public static class c {
        public final List<f> a;
        public final int[] b;
        public final int[] c;
        public final b d;
        public final int e;
        public final int f;
        public final boolean g;

        public c(b bVar, List<f> list, int[] iArr, int[] iArr2, boolean z) {
            this.a = list;
            this.b = iArr;
            this.c = iArr2;
            Arrays.fill(iArr, 0);
            Arrays.fill(iArr2, 0);
            this.d = bVar;
            com.liuzh.deviceinfo.card.CpuStatusCard.b bVar2 = (com.liuzh.deviceinfo.card.CpuStatusCard.b) bVar;
            int size = bVar2.a.size();
            this.e = size;
            int size2 = bVar2.b.size();
            this.f = size2;
            this.g = z;
            f fVar = list.isEmpty() ? null : (f) list.get(0);
            if (!(fVar != null && fVar.a == 0 && fVar.b == 0)) {
                fVar = new f();
                fVar.a = 0;
                fVar.b = 0;
                fVar.d = false;
                fVar.c = 0;
                fVar.e = false;
                list.add(0, fVar);
            }
            for (int size3 = list.size() - 1; size3 >= 0; size3--) {
                f fVar2 = (f) this.a.get(size3);
                int i = fVar2.a;
                int i2 = fVar2.c;
                i += i2;
                int i3 = fVar2.b + i2;
                if (this.g) {
                    while (size > i) {
                        int i4 = size - 1;
                        if (this.b[i4] == 0) {
                            a(size, size2, size3, false);
                        }
                        size = i4;
                    }
                    while (size2 > i3) {
                        i2 = size2 - 1;
                        if (this.c[i2] == 0) {
                            a(size, size2, size3, true);
                        }
                        size2 = i2;
                    }
                }
                for (size2 = 0; size2 < fVar2.c; size2++) {
                    size = fVar2.a + size2;
                    i = fVar2.b + size2;
                    i2 = this.d.a(size, i) ? 1 : 2;
                    this.b[size] = (i << 5) | i2;
                    this.c[i] = (size << 5) | i2;
                }
                size = fVar2.a;
                size2 = fVar2.b;
            }
        }

        public static d b(List<d> list, int i, boolean z) {
            int size = list.size() - 1;
            while (size >= 0) {
                d dVar = (d) list.get(size);
                if (dVar.a == i && dVar.c == z) {
                    list.remove(size);
                    while (size < list.size()) {
                        d dVar2 = (d) list.get(size);
                        dVar2.b += z ? 1 : -1;
                        size++;
                    }
                    return dVar;
                }
                size--;
            }
            return null;
        }

        public final boolean a(int i, int i2, int i3, boolean z) {
            int i4;
            int i5;
            if (z) {
                i2--;
                i4 = i;
                i5 = i2;
            } else {
                i5 = i - 1;
                i4 = i5;
            }
            while (i3 >= 0) {
                f fVar = (f) this.a.get(i3);
                int i6 = fVar.a;
                int i7 = fVar.c;
                i6 += i7;
                int i8 = fVar.b + i7;
                i7 = 8;
                if (z) {
                    for (i4--; i4 >= i6; i4--) {
                        if (this.d.b(i4, i5)) {
                            if (!this.d.a(i4, i5)) {
                                i7 = 4;
                            }
                            this.c[i5] = (i4 << 5) | 16;
                            this.b[i4] = (i5 << 5) | i7;
                            return true;
                        }
                    }
                    continue;
                } else {
                    for (i2--; i2 >= i8; i2--) {
                        if (this.d.b(i5, i2)) {
                            if (!this.d.a(i5, i2)) {
                                i7 = 4;
                            }
                            i--;
                            this.b[i] = (i2 << 5) | 16;
                            this.c[i2] = (i << 5) | i7;
                            return true;
                        }
                    }
                    continue;
                }
                i4 = fVar.a;
                i2 = fVar.b;
                i3--;
            }
            return false;
        }
    }

    /* compiled from: DiffUtil */
    public static class d {
        public int a;
        public int b;
        public boolean c;

        public d(int i, int i2, boolean z) {
            this.a = i;
            this.b = i2;
            this.c = z;
        }
    }

    /* compiled from: DiffUtil */
    public static class e {
        public int a;
        public int b;
        public int c;
        public int d;

        public e(int i, int i2, int i3, int i4) {
            this.a = i;
            this.b = i2;
            this.c = i3;
            this.d = i4;
        }
    }

    /* compiled from: DiffUtil */
    public static class f {
        public int a;
        public int b;
        public int c;
        public boolean d;
        public boolean e;
    }
}
